{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "2852eb93-cc1f-45ce-98b3-0bc16c4bcb6b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入三角形的边A：    3\n",
      "请输入三角形的边B：    5\n",
      "请输入三角形的边C：    4\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "三角形三边分别为： a=3.0, b=5.0, c=4.0\n",
      "12.0 6.0\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "a=float(input(\"请输入三角形的边A：   \"))\n",
    "b=float(input(\"请输入三角形的边B：   \"))\n",
    "c=float(input(\"请输入三角形的边C：   \"))\n",
    "if (a > 0 and b > 0 and c > 0 and a + b > c and a + c > b and b + c > a):\n",
    "    print(str.format(\"三角形三边分别为： a={0}, b={1}, c={2}\", a, b, c))\n",
    "    p = a + b + c\n",
    "    h = p / 2\n",
    "    area = math.sqrt(h * (h - a) * (h - b) * (h - c))\n",
    "    #print(str.format(\"三角形的周长 = {0:2.1f}，面积 = {1:2.1f}\", p, area))\n",
    "    print(p,area)\n",
    "else: print(\"无法构成三角形！\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "79b05a6c-602b-4602-a0ad-ed3f784cfaa0",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
